<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button id="myBtn">点我</button>
<script>
    class App {
        constructor(name, age) {
            this.btn = document.querySelector('#myBtn');
            this.btn.onclick = this.sing;
            //这里的sing方法不能加() 在实例化对象的时候就会执行了，点击按钮不会再执行了
            //this.btn.onclick = this.sing();
        }

        sing() {
            console.log("我在唱歌")
        }
    }

    let app = new App("礼拜", 13);
</script>
</body>
</html>